﻿using System;
using System.Collections.Generic;
using System.Web;
using System.IO;

namespace WebForm.Web.Upload
{
    /// <summary>
    /// Summary description for jqueryUploadifyHandler
    /// </summary>
    public class jqueryUploadifyHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");

            HttpPostedFile file = context.Request.Files["FileData"];
            string uploadpath = HttpContext.Current.Server.MapPath(context.Request["folder"] + "\\");

            if (file != null)
            {
                if (!Directory.Exists(uploadpath))
                {
                    Directory.CreateDirectory(uploadpath);
                }
                file.SaveAs(uploadpath + file.FileName);
                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}